<?php

use Doraemon\tools\HhzClient as tHhzClient;
use Biz\service\Goods as sGoods;
use Biz\service\trade\UserAddress;
use Biz\service\GoodsHistory as sGoodsHistory;
/**
 * @deprecated
 */
class GoodsInfoAction extends ActionPlugin
{
	const USER_LEVEL = self::LEVEL_NOTHING;

	public function main()
	{
		$goodsId = $this->getRequest()->getQuery('goods_id', 0);
		$provinceId = $this->getRequest()->getQuery('province_id', 0);
		$cityId = $this->getRequest()->getQuery('city_id', 0);
		$userCityId = UserAddress::getUserDefaultCityCode($this->uid);
		$areaCode = $userCityId ? $userCityId : ($cityId ? $cityId : $provinceId);
		if ($this->appType == tHhzClient::APPTYPE_PARAGRAPH_MINIPROGRAM) {
			$goodsInfo = sGoods::Goods($goodsId, sGoods::FIELDS_GROUP_PARAGRAPH, ['activity_type' => 0, 'area_code' => $areaCode], $this->uid);
            $goodsInfo['recommend_goods'] = \Biz\service\theParagraph\Goods::recommendByCate($goodsId);
			sGoodsHistory::addBrowseHistory($this->uid, $goodsId, sGoodsHistory::APP_SOURCE_THEPARAGRAPG);

		} else {
			throw new Exception('用户来源渠道错误');
		}
		$this->setSuccess($goodsInfo);
	}
}